{include file="public/header" /}
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.inquiry_title}</h3>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <form method="get" action="" name="formSearch" id="formSearch">
        <!--搜索商品-->
        <div class="ds-search-form">
            <dl style="margin-right:0;">
                <dt>商品名称：</dt>
                <dd><input type="text" value="{$Request.get.goods_name|default=''}" name="goods_name" id="search_station_name" class="txt"></dd>
            </dl>
            <dl style="margin-right:0;">
                <dt>供应商：</dt>
                <dd><input type="text" value="{$Request.get.store_name|default=''}" name="store_name" id="store_name" class="txt"></dd>
            </dl>

            <dl style="margin-right:0;">
                <dt>店铺类型</dt>
                <dd id="searchgc_td"></dd>
                <dd>
                    <select name="inquiry_id" id="inquiry_id">
                        <option value="">请选择用户类型</option>
                        {foreach name="inquiry_list" item="v" key="k" }
                        <option value="{$v.id}" {if condition="(!empty($Request.get.inquiry_id) && $Request.get.inquiry_id eq $v.id )" } selected {/if}" >{$v.inquiry_name}</option>
                        {/foreach}
                    </select>
                </dd>
            </dl>

            <dl style="margin-right:0;">
                <dt>工位名称</dt>
                <dd id="searchgc_tds"></dd>
                <dd>
                    <select name="station_id" id="station_ids">
                        <option value="">请选择工位名称</option>
                        {foreach name="station_list" item="v" key="k" }
                        <option value="{$v.station_id}" {if condition="(!empty($Request.get.station_id) && $Request.get.station_id eq $v.station_id )" } selected {/if}" >{$v.station_name}</option>
                        {/foreach}
                    </select>
                </dd>
            </dl>

            <dl style="margin-right:0;">
                <dt>配置选择</dt>
                <dd id=""></dd>
                <dd>
                    <select name="config_id" id="config_id">
                        <option value="">请选择配置选择</option>
                        {foreach name="config_list" item="v" key="k" }
                        <option value="{$k}" {if condition="(!empty($Request.get.config_id) && $Request.get.config_id eq $k )" } selected {/if}" >{$v}</option>
                        {/foreach}
                    </select>
                </dd>
            </dl>

            <div class="btn_group">
                <a href="javascript:void(0);" id="dssubmit" class="btn" title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>
                <a href="{:url('goodinquiry/inquiry_info')}" class="btn btn-default" title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a>
            </div>
        </div>
    </form>

    <table class="ds-default-table">
        <thead>
            <tr class="thead">
                <th>序号</th>
                <th>商品平台号</th>
                <th>商品名称</th>
                <th>{$Think.lang.inquiry_name}</th>
                <th>{$Think.lang.station_name}</th>
                <th>配置类型</th>
                <th>数量</th>
                <th>供应商</th>
                <th>{$Think.lang.created_at}</th>
                <th>{$Think.lang.ds_handle}</th>
            </tr>
        </thead>
        <tbody>
        {notempty name="info_list"}
        {foreach name="info_list" item="v" key="k" }
        <tr class="hover edit" id="ds_row_{$v.id}">
            <td>{$v.id}</td>
            <td>{$v.goods_id}</td>
            <td>{$v.goods_name}</td>
            <td class="">{$v.inquiry_name}</td>
            <td class="">{$v.station_name}</td>
            <td class="">
                {foreach name="config_list" item="va" key="key" }
                    <?php $config = explode(',',$v['good_config']); if(in_array($key,$config)) { echo "<span class='dsui-btn-edit'>".$va."</span>";}  ?>
                {/foreach}
            </td>
            <td> {$v.num} </td>
            <td> {$v.store_name} </td>
            <td> {$v.created_at} </td>

            <td>
                <a href="javascript:dsLayerConfirm('{:url('Goodinquiry/inquiry_del',['id'=>$v.id])}','{$Think.lang.ds_ensure_del}',{$v.id})" class="dsui-btn-del">
                    <i class="iconfont"></i>{$Think.lang.ds_del}
                </a>
            </td>
        </tr>
        {/foreach}
        {else /}
        <tr class="no_data">
            <td colspan="10">{$Think.lang.ds_no_record}</td>
        </tr>
        {/notempty}
        </tbody>
    </table>
</div>

<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script src="{$Think.ADMIN_SITE_ROOT}/js/jquery.goods_class.js"></script>
<script>
    $(function (){
        // 动态获取工位
        $('#inquiry_id').change(function(){
            var inquiry_id = $(this).val();
            $.ajax({
                type: 'post',
                url: ADMINSITEURL + '/Goodinquiry/get_station',
                data: {'inquiry_id' : inquiry_id},
                dataType: 'json',
                success: function(res) {
                    if(res.code > 0) {
                        var options = '';
                        $.each(res.data, function(idx, obj) {
                            options += "<option value='"+ obj.station_id +"'>" + obj.station_name +"</option>"
                        });
                        $('#station_ids').append(options);
                    } else {
                        $('#station_ids').empty().append('<option value="0">请选择工位</option>');
                    }
                },
                error: function () {
                    layer.msg('系统繁忙，请稍后再试！');
                }
            })
        });

        $(function (){
            $('#dssubmit').click(function(){
                $('#formSearch').submit();
            });
        });
    });
</script>